﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    @Html.Partial("ViewLibrary")
    <link href="~/Content/Styles/Manage_Order.css" rel="stylesheet" />
    <link href="~/Content/Styles/Order.css" rel="stylesheet" />
    <title>Index</title>
    <script>
        $(document).ready(function () {
            GetMer();

            //InitPower();//加载权限

            //var postData = {MerID:11};
            //$.post('/IntegralWater/InitTable', postData).success(function (resp) {
            //    console.log(resp);
            //})
        });

        var UserIntID;//定义用户积分ID
        var Mer;//商户ID
        var diplayText;//商户名称

        //部门选择
        function Dep() {
            $('#SearchDepID').combotree({
                url: '/IntegralWater/getDep',
                method: 'get',
                multiple: false,
            });
        }

        //证件类型
        function acccertype() {
            $.get("/IntegralWater/getacccertype", {}, function (database) {
                $('#SearchAccCerType').combobox({
                    valueField: 'DictKey',
                    textField: 'DictName',
                    data: database
                });
            })
        }

        //获取商户
        function GetMer() {
            var grid = $('#SelectMerID').combogrid({
                panelWidth: 500,
                idField: 'MerID',
                textField: 'MerName',
                url: '/IntegralWater/InitMerID',
                method: 'post',
                pageSize: 5,
                pageList: [5],
                pagination: true,
                rownumbers: true,
                fitColumns: true,
                columns: [[
                    { field: 'MerID', title: '商户ID', width: 80, align: 'center' },
                    { field: 'MerName', title: '商户名称', width: 80, align: 'center' },
                    { field: 'MerTxt', title: '商户介绍', width: 120, align: 'center' },
                    { field: 'MerAdr', title: '商户地址', width: 80, align: 'center' },
                    { field: 'MerCall', title: '商户联系电话', width: 80, align: 'center' }
                ]],
                onSelect: function (index, row) {
                    //alert(1);
                    diplayText = row[grid.combogrid('options').textField];//获取商户名称
                    //alert(diplayText)
                    Mer = $('#SelectMerID').combogrid("getValue");//获取操作员
                    //alert(Mer)
                    //加载对应订单
                    InitTable(Mer);
                    //Dep();//加载组织结构
                    acccertype();//证件类型
                },
                onLoadSuccess: function () {
                    //分页后判断下是否有选中的数据行，combogrid会依据上一次选中的值进行初始化，选中datagrid数据行和设置显示值
                    if (!grid.combogrid('grid').datagrid('getSelected'))//不在当前页
                    {
                        $('#SelectMerID').combogrid("setValue", diplayText);
                    }
                }
            });
        }

        function InitTable(Mer) {
            $('#tab').datagrid({
                fitColumns: true,   // 自动列宽
                autoRowHeight: false,   // 自动行高
                striped: true,  // 是否显示虚线
                nowrap: false,   // 一行数据单行显示
                pagination: true,   // 显示分页导航栏
                rownumbers: false,  // 显示系统行号
                singleSelect: true, // 只允许选择一行
                sortOrder: 'desc',    // 排序方式
                url: '/IntegralWater/InitTable?MerID=' + Mer,    // 数据加载的地址
                method: 'get',  // 请求方法
                loadMsg: '正在加载数据 ...',  // 提示信息
                columns: [[
                    { field: 'FlowIntID', title: '积分流水ID', align: 'center', sortable: true, hidden: true },
                    { field: 'AccNum', title: '账号', align: 'center', sortable: true },
                    { field: 'AccName', title: '姓名', align: 'center', sortable: true },
                    { field: 'IntFlowType_DicName_Dic', title: '流水类型', align: 'center', sortable: true },
                    { field: 'MerName', title: '积分商户', align: 'center', sortable: true },
                    { field: 'IntNowNub', title: '发生前积分数', align: 'center', sortable: true },
                    { field: 'IntHaveNub', title: '本次积分变更', align: 'center', sortable: true },
                    { field: 'IntEndNub', title: '发生后积分数', align: 'center', sortable: true },
                    {
                        field: 'IntFlowTime', title: '发生时间', align: 'center', sortable: true, formatter: function (val)
                        {
                            if (typeof (val) != 'undefined')
                            {
                                var dd = val.substr(0, 4) + "-" + val.substr(4, 2) + "-" + val.substr(6, 2) + " " + val.substr(8, 2) + ":" + val.substr(10, 2) + ":" + val.substr(12, 2);
                            }
                            return dd;
                        }
                    },
                    { field: 'OperNum', title: '经办人', align: 'center', sortable: true },
                    { field: 'OrdrID', title: '关联订单ID', align: 'center', sortable: true },
                    { field: 'IntBZ', title: '备注', align: 'center', sortable: true }
                ]],
                toolbar: '#tb1',
            });
        }
        // 搜索
        function BtnSearch() {
            var SearchAccName = $('#SearchAccName').textbox('getValue');
            var SearchAccCall = $('#SearchAccCall').textbox('getValue');
            var SearchAccIdentifier = $('#SearchAccIdentifier').textbox('getValue');
            //var SearchAccCerType = $('#SearchAccCerType').combobox('getValue');
            //var SearchAccCerNub = $('#SearchAccCerNub').textbox('getValue');
            //var SearchDepID = $('#SearchDepID').combotree('getValue');
            var SearchAccCerType = "";
            var SearchAccCerNub = "";
            var SearchDepID = "";
            //alert(SearchAccCerType + "--" + SearchDepID);
            if (SearchAccName != "" || SearchAccCall != "" || SearchAccIdentifier != "" || SearchAccCerType != "" || SearchAccCerNub != "" || SearchDepID != "") {
                $('#tab').datagrid({
                    url: '/IntegralWater/SeachTable?SearchAccName=' + SearchAccName + '&SearchAccCall=' + SearchAccCall + '&SearchAccIdentifier=' + SearchAccIdentifier + '&SearchAccCerType=' + SearchAccCerType + '&SearchAccCerNub=' + SearchAccCerNub + '&SearchDepID=' + SearchDepID + '&MerID=' + Mer
                });
            } else {
                $.messager.alert("友情提示", "至少填写一个正确的搜索条件");
              
            }
       
        }

        // 查看全部
        function allBtnSearch() {
            InitTable(Mer);
            $('#SearchAccName').textbox('setValue',"");
            $('#SearchAccCall').textbox('setValue',"");
            $('#SearchAccIdentifier').textbox('setValue',"");
        }
    </script>
   @* <script src="~/Content/Script/IntegralWaterController.js"></script>*@
</head>
<body>
        <div style="padding-top: 5px; margin-left: 5px;">
        <b>商户: </b><select id="SelectMerID" name="SelectMerID" style="width: 200px;"></select>
    </div>
    <div id="tb1" style="padding-bottom: 5px; padding-top: 5px; margin-left: 5px;">
        <b>姓名: </b> 
        <input class="easyui-textbox" type="text" id="SearchAccName" name="SearchAccName" style="width: 100px;" />
        <b>手机号: </b> 
        <input class="easyui-textbox" type="text" id="SearchAccCall" name="SearchAccCall" style="width: 100px;" />
        <b>个人编号: </b> 
        <input class="easyui-textbox" type="text" id="SearchAccIdentifier" name="SearchAccIdentifier" style="width: 100px;" />
        @*<b>证件类型: </b> 
        <input class="easyui-combobox" type="text" id="SearchAccCerType" name="SearchAccCerType" style="width: 100px;" />*@
        @*@Html.DropDownList("SearchAccCerType", @ViewBag.AccCerTypeList as List<SelectListItem>, new { @class = "easyui-combobox", name = "SearchAccCerType", style="width: 100px;" })*@
        @*<b>证件号: </b> 
        <input class="easyui-textbox" type="text" id="SearchAccCerNub" name="SearchAccCerNub" style="width: 100px;" />*@
        @*<b>组织结构: </b> 
        <input class="easyui-combotree" type="text" id="SearchDepID" name="SearchDepID" style="width: 100px;" />*@
        @*@Html.DropDownList("SearchDepID", @ViewBag.DepIDList as List<SelectListItem>, new { @class = "easyui-combobox", name = "SearchDepID", style="width: 100px;" })*@

        <button id="BtnSearch" onclick="BtnSearch()" class="easyui-linkbutton" data-options="iconCls:'icon-search'">搜索</button>
        &nbsp; &nbsp; &nbsp; &nbsp;
        <button  onclick="allBtnSearch()" class="easyui-linkbutton" data-options="iconCls:'icon-search'">查看全部</button>
    </div>
    <table id="tab"style="width: auto;"></table>
    <div id="dia"></div>
    <input type="hidden" id="UserPowers" name="UserPowers" value="@ViewBag.UserPowers" />
</body>
</html>
